package io.github.iogogogo.api;

import io.github.iogogogo.commons.support.VersionManager;
import io.github.iogogogo.commons.support.wrapper.BaseResult;
import io.github.iogogogo.commons.support.wrapper.ResponseWrapper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author tao.zeng6@asiainfo.com
 * @since 2025/7/30 11:16
 */
@Slf4j
@RequiredArgsConstructor
@Tag(name = "版本信息")
@RestController
@RequestMapping("/api/version")
@ConditionalOnBean(VersionManager.class)
public class VersionApi implements BaseResult {

    private final VersionManager versionManager;

    @Operation(summary = "获取版本信息")
    @GetMapping("/info")
    public ResponseWrapper<?> info() {
        return ok(versionManager.versionInfo());
    }
}
